/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yaps.petstore.factory;

import com.yaps.petstore.dao.CustomerDAO;
import com.yaps.petstore.service.AccountService;
import com.yaps.petstore.service.CatalogService;
import com.yaps.petstore.service.OrderService;
import com.yaps.petstore.service.ShoppingCartService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.jms.listener.DefaultMessageListenerContainer;

/**
 *
 * @author pfa
 */
public class ServiceLocator {
   
    private static String path ="spring-context.xml";
    private static String pathjms ="spring-jms.xml";
    
    public static AccountService getCustomerService()
    {
        ApplicationContext context = new ClassPathXmlApplicationContext(path);
        return (AccountService) context.getBean("AccountService");
    }
    
    
    public static CatalogService getCatalogService()
    {
        ApplicationContext context = new ClassPathXmlApplicationContext(path);
        return (CatalogService) context.getBean("CatalogService");
    }
    
      public static OrderService getOrderService()
    {
        ApplicationContext context = new ClassPathXmlApplicationContext(path);
        return (OrderService) context.getBean("OrderService");
    }
      
      
      
    public static DefaultMessageListenerContainer initOrderListener()
    {
       ApplicationContext context = new ClassPathXmlApplicationContext(pathjms);
        return (DefaultMessageListenerContainer)context.getBean("jmsContainerOrder");
    }
    
      
    
    
    
}
